const baseApi = process.env.DAP_API_BASE_URL

export function baseApiF() {
  return baseApi
}
//所有筛选下拉框数据接口
export function getSearchItems(url) {
  let Url = baseApi + url;
  return window.axios.get(Url)
    .then((res) => {
      /* console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

// 定点医院医疗费用控制监测分析
export function getChartItem1(url, areaCode, costType, medicalCategory) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
    costType,
    medicalCategory
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /* console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

// 区域医疗费用增长同比分析TOP8
export function getChartItem2(url, areaCode, queryYear, hospLevel) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
    hospLevel,
    queryYear
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

// 2013年-2018年患者次/人均费用增长趋势分析
export function getChartItem3(url, areaCode, medicalCategory, countAvgFlag) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
    countAvgFlag,
    medicalCategory
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

// 患者人均/次均医药费用增长比较分析TOP6
export function getChartItem4(url, areaCode, countAvgFlag, medicalCategory, queryYear) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
    countAvgFlag,
    medicalCategory,
    queryYear
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
// 2013年-2018年参保患者个人支出比例增长趋势分析
export function getChartItem5(url, areaCode, medicalCategory, hospLevel) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
    hospLevel,
    medicalCategory
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
// 参保患者个人支出比例分解分析
export function getChartItem6(url, year, planAreaId, hospitalId, insuredTypeId) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    year,
    planAreaId,
    hospitalId,
    insuredTypeId
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
// 2013年-2018年医保目录外费用比例增长趋势分析
export function getChartItem7(url, areaCode, medicalCategory, hospLevel) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
    medicalCategory,
    hospLevel
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
// 医保目录外费用比例比较分析TOP6
export function getChartItem8(url, areaCode, hospLevel, medicalCategory, queryYear) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
    hospLevel,
    medicalCategory,
    queryYear
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      /*console.log(JSON.stringify(error))*/
      return Promise.reject(error)
    })
}

// 定点医院医疗费用控制监测分析详情
export function getChartItemDetail1(url, queryYear, areaCode, costType, medicalCategory) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
    queryYear,
    costType,
    medicalCategory
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

//
export function getChartItemDetail2(url, areaCode, queryYear, costType, medicalCategory) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
    queryYear,
    costType,
    medicalCategory
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
//五险目标列表
export function getFiveRisksIncome(url, year, month, insuredType) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    year,
    month,
    insuredType
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
//五险目标导出
export function getFiveRisksExportExcel(url, year, month, insuredType, rankArr) {
  let rankStr = ''
  rankArr.map((item, index) => {
    item = `&rankArr=${item}`
    rankStr = rankStr + item;
  })
  let Url = baseApi + `${url}?year=${year}&month=${month}&insuredType=${insuredType}${rankStr}`;
  return Url
}

//编辑报表目标
export function setEditNum(url, reportNumber, year, areaCode, setValue) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    reportNumber,
    year,
    areaCode,
    setValue
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

//养老新增 列表
export function getPensionAddList(url, year, month) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    year,
    month
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

//养老新增导出
export function getPensionAddExportExcel(url, year, month, topRank, downRank) {
  let rankStr = '';
  let rank1Str = ''
  topRank.map((item, index) => {
    item = `&topRank=${item}`
    rankStr = rankStr + item;
  })
  downRank.map((item, index) => {
    item = `&downRank=${item}`
    rank1Str = rank1Str + item;
  })
  let Url = baseApi + `${url}?year=${year}&month=${month}${rankStr}${rank1Str}`;
  return Url
}


//部门 列表
export function getDepartmentList(url, deptName, pageNum, pageSize) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    deptName,
    pageNum,
    pageSize
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

//部门是否启用
export function isEnable(url, deptId, isRun) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    deptId,
    isRun
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

//获取所属单位
export function getSubordinateUnit(url) {
  let Url = baseApi + url;
  const data = Object.assign({}, {})
  return window.axios.post(Url)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

//部门添加
export function addDepartment(url, deptName, deptDesc, dictId) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    deptName,
    deptDesc,
    dictId
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
//部门编辑
export function updateDepartment(url, deptName, deptDesc, dictId, deptId) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    deptName,
    deptDesc,
    dictId,
    deptId
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}
//部门删除
export function delDepartment(url, deptId) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    deptId
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

//左侧菜单栏
export function getLeftBar(url, userId) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    userId
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

// 三期接口
//养老支出的构成
export function getPensionOutComponent(url, areaCode, queryYear) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
    queryYear
  })
  return window.axios.post(Url, data)
    .then((res) => {
      /*console.log(res.data)*/
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error))
      return Promise.reject(error)
    })
}

// 历年养老支出分析
export function getYearPensionExpenditure(url, areaCode) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
  });
  return window.axios.post(Url, data)
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error));
      return Promise.reject(error)
    })
}

// 历年个人养老保险待遇分析
export function getLiNianGeRenYangLaoAnalysis(url, areaCode) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
  });
  return window.axios.post(Url, data)
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error));
      return Promise.reject(error)
    })
}
// 养老支出月度分析
export function getMonthPensionExpenditure(url, queryYear, areaCode) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    queryYear,
    areaCode,
  });
  return window.axios.post(Url, data)
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error));
      return Promise.reject(error)
    })
}

// 个人养老保险待遇月度分析
export function getGeRenYueDuYangLaoAnalysis(url, queryYear, areaCode) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    queryYear,
    areaCode,
  });
  return window.axios.post(Url, data)
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error));
      return Promise.reject(error)
    })
}

// 个人养老保险待遇月度分析 /eipay/basedOnPerson
export function getEiPayBasedOnPerson(url, queryYear, areaCode, ageGroup, compType, occuType, sex) {
  let Url = baseApi + url;
  ageGroup == 0 ? ageGroup = '' : ageGroup;
  compType == 0 ? compType = '' : compType;
  occuType == 0 ? occuType = '' : occuType;
  sex == 0 ? sex = '' : sex;
  const data = Object.assign({}, {
    queryYear,
    areaCode,
    ageGroup: ageGroup,
    compType: compType,
    occuType: occuType,
    sex: sex
  });
  return window.axios.post(Url, data)
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error));
      return Promise.reject(error)
    })
}
//基于缴费基数的单位分析 PersonPayBaseOrgAnalysis
export function getPersonPayBaseOrgAnalysis(url, queryYear, areaCode, insuredType) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    queryYear,
    areaCode,
    insuredType
  });
  return window.axios.post(Url, data)
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error));
      return Promise.reject(error)
    })
}
// person/payBaseAnalysisDetail 基于缴费基数的单位分析
export function getPersonPayBaseAnalysisDetail(url, queryYear, areaCode, insuredType, ecoType, unitType,industryCode) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    queryYear,
    areaCode,
    insuredType,
    ecoType,
    unitType,
    industryCode
  });
  return window.axios.post(Url, data)
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error));
      return Promise.reject(error)
    })
}

// 缴费人数分析 /person/payNumberAnalysis
export function getPayNumberAnalysis(url, areaCode, insuredType, queryYear) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    queryYear,
    areaCode,
    insuredType
  });
  return window.axios.post(Url, data)
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error));
      return Promise.reject(error)
    })
}

// 缴费趋势分析 /person/payNumberDetailAnalysis
export function getPayNumberDetailAnalysis(url, queryYear, areaCode, insuredType) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    queryYear,
    areaCode,
    insuredType
  });
  return window.axios.post(Url, data)
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error));
      return Promise.reject(error)
    })
}
// 基于缴费基数的缴费水平分析  /PensionFundMonitor/ByJiaoFeiJiShuJiaoFeiAnalysis
export function getByJiaoFeiJiShuJiaoFeiAnalysis(url, areaCode, baoXianType, workStatus) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,
    baoXianType,
    workStatus
  });
  return window.axios.post(Url, data)
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error));
      return Promise.reject(error)
    })
}

// 综合决策分析下转查询 /report/queryCompoundDecisionDetail
export function getQueryCompoundDecisionDetail (url, areaCode, insuredType, sex, startAge, endAge, compType, occuType, emplState) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    areaCode,         // 统筹区域
    insuredType,      // 险种类型
    sex,              // 性别
    startAge,         // 起始年龄
    endAge,           // 结束年龄
    compType,         // 单位类型
    occuType,         // 职业类型
    emplState,        // 就业状态

  });
  return window.axios.post(Url, data)
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error));
      return Promise.reject(error)
    })
}

// 缴费基数 report/queryPayPersonDistriSitu
export function getQueryPayPersonDistriSitu (url, queryYear, areaCode, insuredType, sex, startAge, endAge, compType, occuType, emplState, paymentBase) {
  let Url = baseApi + url;
  const data = Object.assign({}, {
    queryYear,        // 年份
    areaCode,         // 统筹区域
    insuredType,      // 险种类型
    sex,              // 性别
    startAge,         // 起始年龄
    endAge,           // 结束年龄
    compType,         // 单位类型
    occuType,         // 职业类型
    emplState,        // 就业状态
    paymentBase,      // 征缴基数

  });
  return window.axios.post(Url, data)
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((error) => {
      console.log(JSON.stringify(error));
      return Promise.reject(error)
    })
}

// 就诊人员分布情况 report/queryJiuZhenDetail
 export function getQueryJiuZhenDetail (url, queryYear, countType, areaCode, hospLevel, hospCode, sex, startAge, endAge,
                                        startTime, endTime, compType, medicalType,) {
   let Url = baseApi + url;
   const data = Object.assign({}, {
     queryYear, // 年份
     countType, // 统计类型: 1按月统计,2按天统计
     areaCode, // 统筹区域
     hospLevel, // 医院等级
     hospCode, // 定点医疗机构编码
     sex, // 性别: 空字符串->全部性别;1男;2女;3未知
     startAge, // 起始年龄
     endAge, // 结束年龄
     startTime, // 起始就诊时间
     endTime, // 结束就诊时间
     compType, // 单位类型:空字符串->全部单位;1企业;2事业单位;3灵活就业; 9其它
     medicalType, // 医疗类型:空字符串->全部医疗类型;21,24住院;15门慢;11普门;26转院;9其它

   });
   return window.axios.post(Url, data)
     .then((res) => {
       return Promise.resolve(res.data)
     })
     .catch((error) => {
       console.log(JSON.stringify(error));
       return Promise.reject(error)
     })
 }

 // 职业分布按月或者天查询
 export function getQueryJiuZhenTimeDetail (url, queryYear, countType, areaCode, hospLevel, hospCode, sex, startAge, endAge,
                                        startTime, endTime, compType, medicalType,) {
   let Url = baseApi + url;
   const data = Object.assign({}, {
     queryYear, // 年份
     countType, // 统计类型: 1按月统计,2按天统计
     areaCode, // 统筹区域
     hospLevel, // 医院等级
     hospCode, // 定点医疗机构编码
     sex, // 性别: 空字符串->全部性别;1男;2女;3未知
     startAge, // 起始年龄
     endAge, // 结束年龄
     startTime, // 起始就诊时间
     endTime, // 结束就诊时间
     compType, // 单位类型:空字符串->全部单位;1企业;2事业单位;3灵活就业; 9其它
     medicalType, // 医疗类型:空字符串->全部医疗类型;21,24住院;15门慢;11普门;26转院;9其它

   });
   return window.axios.post(Url, data)
     .then((res) => {
       return Promise.resolve(res.data)
     })
     .catch((error) => {
       console.log(JSON.stringify(error));
       return Promise.reject(error)
     })
 }


 // 单病种就诊人员分布情况 report/querySingleJiuZhenDetail
 export function getQuerySingleJiuZhenDetail (url, queryYear, countType, areaCode,
                                              hospLevel, hospCode, sex,
                                              startAge, endAge, startTime,
                                              endTime, medicalType, diseaseCode) {
   let Url = baseApi + url;
   const data = Object.assign({}, {
     queryYear, // 年份
     countType, // 统计类型: 1按月统计,2按天统计
     areaCode, // 统筹区域
     hospLevel, // 医院等级
     hospCode, // 定点医疗机构编码
     sex, // 性别: 空字符串->全部性别;1男;2女;3未知
     startAge, // 起始年龄
     endAge, // 结束年龄
     startTime, // 起始就诊时间
     endTime, // 结束就诊时间
     medicalType, // 医疗类型:空字符串->全部医疗类型;21,24住院;15门慢;11普门;26转院;9其它
     diseaseCode, // 病种编码
   });
   return window.axios.post(Url, data)
     .then((res) => {
       return Promise.resolve(res.data)
     })
     .catch((error) => {
       console.log(JSON.stringify(error));
       return Promise.reject(error)
     })
 }
